package de.age.engine.controller;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;

import de.age.engine.model.render.assets.Asset;
import de.age.engine.model.render.assets.EAsset;

/**
 * 
 * @author Philipp Sigloch
 * 
 */
public class AssetManager {
	
	private static AssetManager instance = null;
	
	
	/**
	 * @return the current instance of the asset manager *
	 */
	public static AssetManager instance() {
		if (AssetManager.instance == null) {
			AssetManager.instance = new AssetManager();
		}
		return AssetManager.instance;
	}
	
	private AssetManager() {
		// nothing to do here
	}
	
	
	private Array<Asset> loadQueue = new Array<Asset>();
	
	private ObjectMap<String, Texture> textureMap = new ObjectMap<String, Texture>();
	
	private ObjectMap<String, Animation> animationMap = new ObjectMap<String, Animation>();
	
	
	// TODO: Add other needed ... proof of concept is done
	
	public void add(String identifier, String path, EAsset type) {
		this.loadQueue.add(new Asset(identifier, path, type));
	}
	
	public void add(Asset asset) {
		this.loadQueue.add(asset);
	}
	
	public void processQueue() {
		for (Asset asset : this.loadQueue) {
			
		}
	}
	
	public Object get(String identifier, EAsset type) {
		switch (type) {
		case Animation:
			return this.animationMap.get(identifier);
		case Music:
			// TODO: implement
			break;
		case Music_short:
			// TODO: implement
			break;
		case Particle:
			// TODO: implement
			break;
		case Texture:
		case TextureArea:
		case TextureMap:
			return this.textureMap.get(identifier);
		default:
			break;
		
		}
		return null;
	}
	
	private void loadTexture() {
	}
	
	private void loadTextureMap() {
	}
	
	private void loadAnimation() {
	}
	
	private void loadMusic() {
		
	}
	// TODO MORE TO COME
}
